namespace SubhadraSolutions.Sharp.Logging
{
    using System.Collections.Generic;

    using SubhadraSolutions.Sharp.Utils.Contracts;

    public sealed class ThreadIdComparer : IComparer<LogStoreItem>
    {
        #region Fields

        private static readonly ThreadIdComparer _instance = new ThreadIdComparer();

        #endregion Fields

        #region Constructors

        private ThreadIdComparer()
        {
        }

        #endregion Constructors

        #region Properties

        public static ThreadIdComparer Instance
        {
            get { return _instance; }
        }

        #endregion Properties

        #region Methods

        public int Compare(LogStoreItem x, LogStoreItem y)
        {
            int result = x.ThreadId.CompareTo(y.ThreadId);
            return result != 0 ? result : x.TimeStamp.CompareTo(y.TimeStamp);
        }

        #endregion Methods
    }
}